define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'mall_order/index',
                    //add_url: 'mall_order/add',
                    //edit_url: 'mall_order/edit',
                    //del_url: 'mall_order/del',
                    multi_url: 'mall_order/multi',
                    table: 'mall_order',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                showToggle: false,
                showExport: false,
                searchFormVisible: false, //是否始终显示搜索表单
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'sn', title: __('Sn'),
                            formatter: function(row,data){
                                console.log(row,data)
                                let html = '<div class="btn_sn" data-sn="'+data.sn+'" data-id="'+data.id+'">'+data.sn+'</div>'
                                //`<span class="icon-open">+</span>${data.goodsspec.length}项`
                                return html
                            }},
                        {field: 'user.username', title: __('Username'),operate:false},
                        {field: 'user.mobile', title: __('Mobile'),operate:false},
                        {field: 'type', title: __('type'), searchList: {"1":__('type 1'),"2":__('type 2')}, formatter: Table.api.formatter.normal},
                        {field: 'mallordergoods.goods_name', title: __('Goods_name'),operate:false},
                        {field: 'amount', title: __('Amount'), operate:'BETWEEN'},
                        {field: 'pay_amount', title: __('Pay_amount'), operate:'BETWEEN'},
                        {field: 'flag', title: __('Flag'), searchList: {"1":__('Flag 1'),"2":__('Flag 2')}, formatter: Table.api.formatter.normal},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'pay_time', title: __('Pay_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4'),"5":__('Status 5')}, formatter: Table.api.formatter.status},
                        {field: 'operate', title: __('Operate'), table: table,
                            events: {
                                'click .btn-duplicate1': function (e, value, row) {
                                    Layer.open({
                                        type: 2,
                                        content:'order/detail/ids/{ids}',
                                        area:['900px','600px'],
                                        //content: Config.url
                                    })
                                    //Layer.prompt({
                                    //    title: "请填写审核备注",
                                    //    success: function (layero) {
                                    //        $("input", layero).prop("placeholder", "备注");
                                    //    }
                                    //}, function (value) {
                                    //    Fast.api.ajax({
                                    //        url: "orderrefund/change/ids/" + row.id,
                                    //        data: {admin_note: value, status: "1"},
                                    //    }, function (data, ret) {
                                    //        Layer.closeAll();
                                    //        $(".btn-refresh").trigger("click");
                                    //        //return false;
                                    //    });
                                    //});
                                    return false;
                                },
                            },
                            buttons: [
                                {
                                    name: '打印收据',
                                    text: __('打印收据'),
                                    classname: 'btn btn-xs btn-warning btn-duplicate1',
                                    icon: 'fa fa-copy',
                                    visible: function (row) {
                                        return true;
                                    }
                                },
                                {
                                    name: '打印收藏',
                                    title: __('打印收藏'),
                                    classname: 'btn btn-xs btn-info btn-dialog',
                                    icon: 'fa fa-asterisk',
                                    url: 'order/detail/ids/{ids}',
                                    extend: 'data-area=["70%","70%"]',
                                }
                                //{
                                //    name: 'detail',
                                //    title: __('打印收藏'),
                                //    classname: 'btn btn-xs btn-info btn-dialog',
                                //    icon: 'fa fa-asterisk',
                                //    url: 'order/detail/ids/{ids}',
                                //    extend: 'data-area=["70%","70%"]',
                                //}

                            ], formatter: Table.api.formatter.operate}
                    ]
                ]
            });
            var submitForm = function (ids, layero) {
                var options = table.bootstrapTable('getOptions');
                var columns = [];
                var search = options.queryParams({});
                $.each(options.columns[0], function (i, j) {
                    if (j.field && !j.checkbox && j.visible && j.field != 'operate') {
                        columns.push(j.field);
                    }
                });
                columns = columns.join(',');
                $("input[name=search]", layero).val(options.queryParams({}));
                $("input[name=filter]", layero).val(search.filter);
                $("input[name=op]", layero).val(search.op);
                $("input[name=columns]", layero).val(columns);
                $("input[name=ids]", layero).val(ids);
                $("form", layero).submit();
            };
            $(document).on("click", ".btn-export", function () {
                let user_auth = Config.user_auth;
                if (user_auth.export_status == 2) {
                    layer.msg('您申请的' + user_auth.title + '导出数据权限已被拒绝！！！');
                    return false;
                }
                if (user_auth.group_id != 1 && user_auth.export_status != 1) {
                    layer.confirm('您没有权限导出数据，点击确定按钮申请', function () {
                        var data = {};
                        data ['row[rule_id]'] = user_auth.rule_id;
                        Fast.api.ajax({
                            data: data,
                            url: 'export_auth/apply',
                        }, function (data, ret) { //success
                            layer.msg(ret.msg);
                            setTimeout(function () {
                                Fast.api.close();
                            }, 1000)
                            return false;
                        }, function (data, ret) { //error
                            layer.msg(ret.msg);
                            return false;
                        });
                    });
                    return false;
                }
                var ids = Table.api.selectedids(table);
                var page = table.bootstrapTable('getData');
                var all = table.bootstrapTable('getOptions').totalRows;
                Layer.confirm("请选择导出的选项<form action='" + Fast.api.fixurl(user_auth.url) + "' method='post' target='_blank'><input type='hidden' name='ids' value='' /><input type='hidden' name='filter' ><input type='hidden' name='op'><input type='hidden' name='search'><input type='hidden' name='columns' value='' /></form>", {
                    title: '导出数据',
                    btn: ["选中项(" + ids.length + "条)", "本页(" + page.length + "条)", "全部(" + all + ")"],
                    success: function (layero, index) {
                        $(".layui-layer-btn a", layero).addClass("layui-layer-btn0");
                    },
                    yes: function (index, layero) {
                        submitForm(ids.join(","), layero);
                        return false;
                    },
                    btn2: function (index, layero) {
                        var ids = [];
                        $.each(page, function (i, j) {
                            ids.push(j.id);
                        });
                        submitForm(ids.join(","), layero);
                        return false;
                    }
                    ,
                    btn3: function (index, layero) {
                        submitForm("all", layero);
                        return false;
                    }
                })
            });

            $(document).on('click','.btn_sn' ,function (e) {
                console.log( $(this).data('sn'))
                Layer.open({
                    type: 2,
                    content:'goods/purchaseDetail?sn='+$(this).data('sn')+'&ids='+$(this).data('id'),
                    area:['100%','100%'],
                    //content: Config.url
                })
            })
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        orderdetail: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'mall_order/orderdetail',
                    multi_url: 'mall_order/multi',
                    table: 'mall_order',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                showToggle: false,
                showExport: false,
                searchFormVisible: false, //是否始终显示搜索表单
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        //{field: 'sn', title: __('Sn'),operate:'like'},
                        {field: 'sn', title: __('Sn'),
                            formatter: function(row,data){
                                console.log(row,data)
                                let html = '<div class="btn_sn" data-sn="'+data.sn+'" data-id="'+data.id+'">'+data.sn+'</div>'
                                //`<span class="icon-open">+</span>${data.goodsspec.length}项`
                                return html
                            }},
                        {field: 'user.username', title: __('Username'),operate:false},
                        {field: 'user.mobile', title: __('Mobile'),operate:false},
                        {field: 'type', title: __('type'), searchList: {"1":__('type 1'),"2":__('type 2')}, formatter: Table.api.formatter.normal},
                        {field: 'mallordergoods.goods_name', title: __('Goods_detail_name'),operate:false},
                        {field: 'mallordergoods.unit_price', title: __('Unit_price'),operate:false},
                        {field: 'mallordergoods.buy_nums', title: __('Buy_nums'),operate:false},
                        {field: 'mallordergoods.total_price', title: __('Total_price'),operate:false},
                        {field: '', title: __('Derate_type'),operate:false},
                        {field: '', title: __('Coupons'),operate:false},
                        {field: 'amount', title: __('Amount_detail'), operate:'BETWEEN'},
                        {field: 'pay_amount', title: __('Pay_amount_detail'), operate:'BETWEEN'},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                    ]
                ]
            });

            $(document).on('click','.btn_sn' ,function (e) {
                console.log( $(this).data('sn'))
                Layer.open({
                    type: 2,
                    content:'goods/purchaseDetail?sn='+$(this).data('sn')+'&ids='+$(this).data('id'),
                    area:['100%','100%'],
                    //content: Config.url
                })
            })
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        //未付款
        unpay: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'order/unpay',
                    edit_url: 'order/edit',
                    del_url: 'order/del',
                    table: 'order',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                showToggle: false,
                showExport: false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'member.nickname', title: __('Member.nickname'),operate:'like'},
                        {field: 'member.header_img', title: __('Member.header_img'),operate:false,formatter: Table.api.formatter.image},
                        {field: 'sn', title: __('Sn'),operate:'like'},
                        {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4'),"5":__('Status 5')}, formatter: Table.api.formatter.status},
                        {field: 'amount', title: __('Amount'), operate:'BETWEEN'},
                        {field: 'coupon_amount', title: __('Coupon_amount'), operate:'BETWEEN'},
                        {field: 'pay_amount', title: __('Pay_amount'), operate:'BETWEEN'},

                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table,
                            buttons: [
                                {
                                    name: 'detail',
                                    title: __('详情'),
                                    classname: 'btn btn-xs btn-info btn-dialog',
                                    icon: 'fa fa-asterisk',
                                    url: 'order/detail/ids/{ids}',
                                    extend: 'data-area=["70%","70%"]',
                                },
                            ], events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },

        //已付款未发货
        pays: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'order/pays',
                    edit_url: 'order/edit',
                    del_url: 'order/del',
                    table: 'order',
                }
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                showToggle: false,
                showExport: false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'member.nickname', title: __('Member.nickname'),operate:'like'},
                        {field: 'member.header_img', title: __('Member.header_img'),operate:false,formatter: Table.api.formatter.image},
                        {field: 'manystore.nickname', title: __('Manystore.nickname'),operate:'like'},
                        {field: 'goods.title', title: __('商品名称'),operate:false},
                        {field: 'goods.image', title: __('商品图片'),operate:false,formatter: Table.api.formatter.image},
                        {field: 'address.name', title: __('收货人'),operate:false},
                        {field: 'address.mobile', title: __('联系方式'),operate:false},
                        {field: 'address.detail_address', title: __('收货地址'),operate:false},
                        {field: 'sn', title: __('Sn'),operate:'like'},
                        {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4'),"5":__('Status 5')}, formatter: Table.api.formatter.status},
                        {field: 'amount', title: __('Amount'), operate:'BETWEEN'},
                        {field: 'coupon_amount', title: __('Coupon_amount'), operate:'BETWEEN'},
                        {field: 'pay_amount', title: __('Pay_amount'), operate:'BETWEEN'},
                        {field: 'pay_type', title: __('Pay_type'), searchList: {"0":__('Pay_type 0'),"1":__('Pay_type 1'),"2":__('Pay_type 2')}, formatter: Table.api.formatter.normal},
                        {field: 'pay_time', title: __('Pay_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table,
                            buttons: [
                                {
                                    name: 'detail',
                                    title: __('详情'),
                                    classname: 'btn btn-xs btn-info btn-dialog',
                                    icon: 'fa fa-asterisk',
                                    url: 'order/detail/ids/{ids}',
                                    extend: 'data-area=["70%","70%"]',
                                },
                                {
                                    name: 'write',
                                    title: __('到店取货'),
                                    classname: 'btn btn-xs btn-primary btn-magic btn-ajax',
                                    icon: 'fa fa-check',
                                    url: 'order/offline_delivery/ids/{ids}',
                                    confirm: '确认用户到店取货?',
                                    visible: function (row) {
                                        //返回true时按钮显示,返回false隐藏
                                        if(row.distribution == "1")
                                            return true;
                                        else
                                            return false;
                                    },
                                    success: function (data, ret) {
                                        // 刷新页面
                                        $(".btn-refresh").trigger("click");
                                    },
                                    error: function (data, ret) {
                                        console.log(data, ret);
                                        Layer.alert(ret.msg);
                                        return false;
                                    }
                                },
                                {
                                    name: 'received',
                                    title: __('订单发货'),
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    icon: 'fa fa-sign-out',
                                    url: 'order/delivery/ids/{ids}',
                                    visible: function (row) {
                                        //返回true时按钮显示,返回false隐藏
                                        if(row.distribution == "0")
                                            return true;
                                        else
                                            return false;
                                    },
                                    callback: function (data) {

                                        return false;
                                    }
                                },

                            ],
                            events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },

        //已发货未收货
        shipping: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'order/shipping',
                    edit_url: 'order/edit',
                    del_url: 'order/del',
                    table: 'order',
                }
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'update_time',
                sortOrder: 'desc',
                showToggle: false,
                showExport: false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'member.nickname', title: __('Member.nickname'),operate:'like'},
                        {field: 'member.header_img', title: __('Member.header_img'),operate:false,formatter: Table.api.formatter.image},
                        {field: 'goods.title', title: __('商品名称'),operate:false},
                        {field: 'goods.image', title: __('商品图片'),operate:false,formatter: Table.api.formatter.image},
                        {field: 'address.name', title: __('收货人'),operate:false},
                        {field: 'address.mobile', title: __('联系方式'),operate:false},
                        {field: 'address.detail_address', title: __('收货地址'),operate:false},
                        {field: 'sn', title: __('Sn'),operate:'like'},
                        {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4'),"5":__('Status 5')}, formatter: Table.api.formatter.status},
                        {field: 'amount', title: __('Amount'), operate:'BETWEEN'},
                        {field: 'coupon_amount', title: __('Coupon_amount'), operate:'BETWEEN'},
                        {field: 'pay_amount', title: __('Pay_amount'), operate:'BETWEEN'},
                        {field: 'pay_type', title: __('Pay_type'), searchList: {"0":__('Pay_type 0'),"1":__('Pay_type 1'),"2":__('Pay_type 2')}, formatter: Table.api.formatter.normal},
                        {field: 'pay_time', title: __('Pay_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        //{field: 'admin_id', title: __('Admin_id'), operate:false},
                        {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table,
                            buttons: [
                                {
                                    name: 'detail',
                                    title: __('详情'),
                                    classname: 'btn btn-xs btn-info btn-dialog',
                                    icon: 'fa fa-asterisk',
                                    url: 'order/detail/ids/{ids}',
                                    extend: 'data-area=["70%","70%"]',
                                },
                                {
                                    name: 'shipping',
                                    title: __('物流信息'),
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    icon: 'fa fa-truck',
                                    url: 'order/logistics/ids/{ids}',
                                    callback: function (data) {

                                        return false;
                                    }
                                },
                                {
                                    name: 'ajax',
                                    text: __('确认收货'),
                                    title: __('确认收货'),
                                    classname: 'btn btn-xs btn-success btn-magic btn-ajax',
                                    icon: 'fa fa-magic',
                                    url: 'order/received/ids/{ids}',
                                    confirm: '是否确认此订单已收货？',
                                    refresh: true,
                                    success: function (data, ret) {
                                        Layer.alert(ret.msg);
                                        $(".btn-refresh").trigger("click");
                                        //如果需要阻止成功提示，则必须使用return false;
                                        return false;
                                    },
                                    error: function (data, ret) {
                                        console.log(data, ret);
                                        Layer.alert(ret.msg);
                                        return false;
                                    }
                                },

                            ],
                            events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },

        //已完成
        finish: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'order/finish',
                    edit_url: 'order/edit',
                    del_url: 'order/del',
                    table: 'order',
                }
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                showToggle: false,
                showExport: false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'member.nickname', title: __('Member.nickname'),operate:'like'},
                        {field: 'member.header_img', title: __('Member.header_img'),operate:false,formatter: Table.api.formatter.image},
                        {field: 'goods.title', title: __('商品名称'),operate:false},
                        {field: 'goods.image', title: __('商品图片'),operate:false,formatter: Table.api.formatter.image},
                        {field: 'address.name', title: __('收货人'),operate:false},
                        {field: 'address.mobile', title: __('联系方式'),operate:false},
                        {field: 'address.detail_address', title: __('收货地址'),operate:false},
                        {field: 'sn', title: __('Sn'),operate:'like'},
                        {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4'),"5":__('Status 5')}, formatter: Table.api.formatter.status},
                        {field: 'amount', title: __('Amount'), operate:'BETWEEN'},
                        {field: 'coupon_amount', title: __('Coupon_amount'), operate:'BETWEEN'},
                        {field: 'pay_amount', title: __('Pay_amount'), operate:'BETWEEN'},
                        {field: 'pay_type', title: __('Pay_type'), searchList: {"0":__('Pay_type 0'),"1":__('Pay_type 1'),"2":__('Pay_type 2')}, formatter: Table.api.formatter.normal},
                        {field: 'pay_time', title: __('Pay_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {
                            field: 'buttons',
                            width: "120px",
                            title: __('Review_status'),
                            table: table,
                            events: Table.api.events.operate,
                            buttons: [
                                {
                                    name: 'review',
                                    text: __('Review_status 1'),
                                    title: __('评价信息'),
                                    extend: 'data-area=["70%","70%"]',
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    icon: 'fa fa-eyedropper',
                                    url: 'orderreviews/index/ids/{ids}',
                                    visible: function (row) {
                                        //返回true时按钮显示,返回false隐藏
                                        if(row.review_status == "1")
                                            return true;
                                        else
                                            return false;
                                    }
                                },
                            ],
                            formatter: Table.api.formatter.buttons
                        },
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        //{field: 'admin_id', title: __('Admin_id'), operate:false},
                        {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table,
                            buttons: [
                                {
                                    name: 'detail',
                                    title: __('详情'),
                                    classname: 'btn btn-xs btn-info btn-dialog',
                                    icon: 'fa fa-asterisk',
                                    url: 'order/detail/ids/{ids}',
                                    extend: 'data-area=["70%","70%"]',
                                },
                                {
                                    name: 'shipping',
                                    title: __('物流信息'),
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    icon: 'fa fa-truck',
                                    url: 'order/logistics/ids/{ids}',
                                    callback: function (data) {

                                        return false;
                                    }
                                },

                            ],
                            events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },


        //售后订单
        after_sales: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'order/after_sales',
                    edit_url: 'order/edit',
                    del_url: 'order/del',
                    table: 'order',
                }
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                showToggle: false,
                showExport: false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'member.nickname', title: __('Member.nickname'),operate:'like'},
                        {field: 'member.header_img', title: __('Member.header_img'),operate:false,formatter: Table.api.formatter.image},
                        {field: 'goods.title', title: __('商品名称'),operate:false},
                        {field: 'goods.image', title: __('商品图片'),operate:false,formatter: Table.api.formatter.image},
                        {field: 'address.name', title: __('收货人'),operate:false},
                        {field: 'address.mobile', title: __('联系方式'),operate:false},
                        {field: 'address.detail_address', title: __('收货地址'),operate:false},
                        {field: 'sn', title: __('Sn'),operate:'like'},
                        {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4'),"5":__('Status 5')}, formatter: Table.api.formatter.status},
                        {field: 'amount', title: __('Amount'), operate:'BETWEEN'},
                        {field: 'coupon_amount', title: __('Coupon_amount'), operate:'BETWEEN'},
                        {field: 'pay_amount', title: __('Pay_amount'), operate:'BETWEEN'},
                        {field: 'pay_type', title: __('Pay_type'), searchList: {"0":__('Pay_type 0'),"1":__('Pay_type 1'),"2":__('Pay_type 2')}, formatter: Table.api.formatter.normal},
                        {field: 'pay_time', title: __('Pay_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},

                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},

                        //{field: 'refund_status', title: __('Refund_status'), searchList: {"0":__('Refund_status 0'),"1":__('Refund_status 1'),"2":__('Refund_status 2'),"3":__('Refund_status 3'),"4":__('Refund_status 4')}, formatter: Table.api.formatter.normal},
                        {field: 'operate', title: __('Operate'), table: table,
                            buttons: [
                                {
                                    name: 'detail',
                                    title: __('详情'),
                                    classname: 'btn btn-xs btn-info btn-dialog',
                                    icon: 'fa fa-asterisk',
                                    url: 'order/detail/ids/{ids}',
                                    extend: 'data-area=["70%","70%"]',
                                },
                                {
                                    name: 'after_sales',
                                    title: __('售后申请'),
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    icon: 'fa fa-list',
                                    extend: 'data-area=["90%","90%"]',
                                    url: 'orderrefund/index/ids/{ids}',
                                    callback: function (data) {

                                        return false;
                                    }
                                },

                            ],
                            events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },

        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});